<template>
  <div class="bottom">
    <transition
    name="animate__animated animate__heartBeat "
      appear
      enter-active-class="animate__rubberBand "
    >
      <p>总购买数量: {{ totalNumber }}</p>
    </transition>
    
    <p>
      <button class="pay">去结算</button>
      <button class="clear" @click="clearCart">清空购物车</button>
      <button class="clear_select" @click="delAllSelect">删除所有已选中</button>
      <button class="list">返回列表页</button>
    </p>
    <transition
      name="animate__animated animate__heartBeat "
      appear
      enter-active-class="animate__rubberBand "
      >
      <p>
      总价格 : ￥ 
      
      <span>{{ totalPri }}</span>
    </p>
      </transition>
   
  </div>
</template>

<script>
import { mapGetters, mapState,mapMutations, mapActions } from 'vuex';
export default {
  name: "CartFooter",
  
  methods: {
    clearCart() {
      // this.list = [];
      //不要直接操作prop过来的数据
      //而是通知数据的源头 app 我要清空你的数据
      this.$emit("clearCart");
    },
    delAllSelect() {
      //和上面类似
      this.$emit("delAllSelect");
    },
  },
  computed: {
      ...mapState(["list"]),
      ...mapGetters(["totalNumber","totalPri"]),
  
  },
};
</script>

<style>
.bottom {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background-color: pink;
}
.bottom > p {
  font-size: 20px;
}

.bottom > p > button {
  font-size: 20px;
  padding: 3px 10px;
  cursor: pointer;
  color: #fff;
}

.bottom > p > button.pay {
  background-color: green;
}

.bottom > p > button.clear {
  background-color: red;
}

.bottom > p > button.clear_select {
  background-color: orange;
}

.bottom > p > button.list {
  background-color: skyblue;
}

.bottom > p > span {
  color: red;
}
</style>
